package com.behome.netty.netty_A.bean;

import com.behome.netty.common.ByteConventerKit;
import com.behome.netty.common.util.CRCKit;

public abstract class PacketBase {
    protected boolean isSign = false;

    protected byte[] data;

    protected PacketBase(byte[] data) {
        this.data = data;
    }

    public void setSign(boolean isSign) {
        this.isSign = isSign;
    }

    public abstract boolean validateBeforeSerialize();

    public abstract byte[] getSignData(byte[] var1);

    public abstract byte[] serialize();

    public abstract String getPacketInfo();

    public abstract String toDetailString();

    public String toString() {
        return this.getPacketInfo();
    }

    public byte[] getCRC32Bytes(byte[] data) {
        return ByteConventerKit.intToBytes2(CRCKit.crc32Calc(data));
    }
}
